from flask import Flask
from cont import Config
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager
from flask_migrate import Migrate, migrate,MigrateCommand

app = Flask(__name__)
app.config.from_object(Config)
# 初始化
db = SQLAlchemy(app)
manager = Manager(app)
Migrate(app,db)
manager.add_command('db',MigrateCommand)

# orm方式创建表
class User(db.Model):
    __tablename__="user"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(80))


class News(db.Model):
    __tablename__="news"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.String(80))


if __name__ == "__main__":
    db.create_all()
    app.run(debug=True)
    # manager.run()
